package com.jc.service.order;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jc.cds.mapper.CustomXorderMapper;
import com.jc.cds.model.CustomXorder;
import com.jc.ds.base.service.BaseServiceImpl;
import com.jc.ds.model.OrderProducts;
import com.jc.ds.model.Xorder;
import com.jc.service.orderproduct.OrderProductsService;

@Service
public class XorderServiceImpl extends BaseServiceImpl<Xorder, CustomXorder, Long> implements XorderService {

	@Autowired
	OrderProductsService OrderProductsService;
	
	@Override
	public CustomXorderMapper getCustomMapper() {
		return (CustomXorderMapper)getBaseCustomMapper();
	}
	
	public List<CustomXorder> queryWaitPushOrder(){
		return this.getCustomMapper().queryWaitPushOrder();
	}
	
	@Transactional
	public void addOrder(Xorder order, List<OrderProducts> list) {
		if(order != null) {
			add(order, false);
			Long oid = order.getId();
			for(OrderProducts sku : list) {
				sku.setOrderId(oid);
				OrderProductsService.add(sku, false);
			}
			
		}
		
		
	}

	
}
